import axios from "axios";

//  const baseURL = "http://cdn.apc.360.cn";
// const baseURL = "/api";
/**
 * 创建 axios
 */
const service = axios.create({
  baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
  // baseURL,
  // 5s 请求超时
  timeout: 5000, 
  headers:{
	  CacheControl: "max-age=0",
	  UpgradeInsecureRequests: 1,
	  Origin: "http://cdn.apc.360.cn",
	  // UserAgent: "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36 HBuilderX",
	  Accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
	  AcceptEncoding: "gzip, deflate",
	  AcceptLanguage: "zh-CN,zh;q=0.9,zh-TW;q=0.8,en-US;q=0.7,en;q=0.6",
  }
});

/**
 * 请求拦截器
 */
service.interceptors.request.use(
  (config) => {
    return config;
  },
  (error) => {
    console.log(error); // for debug
    return Promise.reject(error);
  }
);
/**
 * 响应拦截器
 */
service.interceptors.response.use(
  (response) => {
    return response;
  },
  (error) => {
    return Promise.reject(error);
  }
);

export default service;
